package cn.newgrand.netcall.consultant;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import cn.newgrand.smackx.consultant.packet.SpecialistVCard;

public class SpecialistVCardManager {
	
	private HashMap<String, SpecialistVCard> vcardInfos = new HashMap<String, SpecialistVCard>(40);
	
	private static SpecialistVCardManager instance = null;
	
	private SpecialistVCardManager(){
		
	}
	
	public synchronized static SpecialistVCardManager getInstance(){
		if(instance == null){
			instance = new SpecialistVCardManager();
		}
		return instance;
	}
	
	public boolean isExistSpecialistVCard(String spid){
		return vcardInfos.containsKey(spid);
	}
	
	public void addSecialistVCard(String spid,SpecialistVCard specialistVCard){
		vcardInfos.put(spid, specialistVCard);
	}
	
	public void removeSpecialistVCard(String spid){
		vcardInfos.remove(spid);
	}
	
	public SpecialistVCard getSpecialistVCard(String spid){
		return vcardInfos.get(spid);
	}
	
	public List<SpecialistVCard> getAllSpecialistVCards(){
		List<SpecialistVCard> list = new ArrayList<SpecialistVCard>(vcardInfos.values());
		List<SpecialistVCard> specialistVcards = Collections.unmodifiableList(list);
		return specialistVcards;
	}

}
